# 荷兰国旗


def partition_01(arr):
    t = arr[0]
    m = -1  # 小于区右边界
    cur = 0
    while cur < len(arr):
        if arr[cur] <= t:
            swap(arr, cur, m + 1)
            m += 1
        cur += 1


def swap(l, a, b):
    l[a], l[b] = l[b], l[a]


if __name__ == '__main__':
    ll = [3, 2, 4, 9, 1, 0,3,5]
    partition_01(ll)
    print(ll)
